package com.hanscan.persistence.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


@Entity
@Table(name = "companies")
@SequenceGenerator(name = "companyGen", sequenceName = "companyGen",
allocationSize = 1)
@NamedQueries(
{
    @NamedQuery(name = "getAllCompaniesOrderByName",
    query = "SELECT g FROM Company g " +
    "WHERE g.resigntDate is null order by g.companyName"),
    @NamedQuery(name = "findCompanyByCompanyId",
    query = "SELECT g FROM Company g " +
    "WHERE g.companyId=?1 AND g.resigntDate is null"),
    @NamedQuery(name = "findCompanyByName",
    query = "SELECT g FROM Company g " +
    "WHERE UPPER(g.companyName) LIKE ?1 AND g.resigntDate = null")


})
public class Company implements Serializable
{

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "companyGen")
    private Long companyId;

    //Atributos
    @Column(nullable = false)
    private String companyName;
    @Temporal(TemporalType.TIMESTAMP)
    private Date resigntDate;


    public Company()
    {
    }

    public Long getCompanyId()
    {
        return companyId;
    }

    public void setCompanyId(Long companyId)
    {
        this.companyId = companyId;
    }

    public String getCompanyName()
    {
        return companyName;
    }

    public void setCompanyName(String companyName)
    {
        this.companyName = companyName;
    }

    public Date getResigntDate()
    {
        return resigntDate;
    }

    public void setResigntDate(Date resigntDate)
    {
        this.resigntDate = resigntDate;
    }

}
